<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
namespace Agp\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Agp\EstoqueBundle\Entity\Item
 *
 * @ORM\Table(name="item_venda")
 * @ORM\Entity(repositoryClass="Agp\CoreBundle\Repository\ItemVendaRepository")
 * @ORM\HasLifecycleCallbacks
 */
class ItemVenda {
    
    /**
     * @var integer $codItemCompra
     *
     * @ORM\Column(name="cod_item_venda", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $codItemVenda;
   
    /**
     * @ORM\ManyToOne(targetEntity="Venda", fetch="LAZY", inversedBy="itens", cascade={"all"})
     * @ORM\JoinColumn(name="cod_venda", referencedColumnName="cod_venda", onDelete="cascade")
     */
    protected $venda;
    
    /**
     * @ORM\ManyToOne(targetEntity="Agp\CoreBundle\Entity\Produto", fetch="LAZY")
     * @ORM\JoinColumn(name="cod_produto", referencedColumnName="cod_produto", onDelete="restrict")
     */
    protected $produto;
    
    /**
     * @ORM\Column(name="nm_ticket", type="integer", nullable=true)
     */
    protected $nmTicket;
    
    /**
     * @ORM\Column(name="placa_vel", type="string", length=7, nullable=true)
     */
    protected $placaVel;
    
    /**
     * @ORM\Column(name="vlr_item", type="float", nullable=false)
     */
    protected $vlrItem;
    
    /**
     * @ORM\Column(name="qtd_item", type="float", nullable=false)
     */
    protected $qtdItem;
    
    /**
     * @ORM\Column(name="subtotal", type="float", nullable=false)
     */
    protected $subtotal;
    
    /**
     * @ORM\ManyToOne(targetEntity="Agp\CoreBundle\Entity\ListaPreco", fetch="LAZY")
     * @ORM\JoinColumn(name="cod_lista", referencedColumnName="cod_lista_preco", onDelete="restrict", nullable=true)
     */
    protected $lista;
    
    const SIT_ATIVO = 'Ativo';
    const SIT_INATIVO = 'Inativo';
    const SIT_CANCELADO = 'Cancelado';
    /**
     * @var string $situacao
     *
     * @ORM\Column(name="situacao", type="string", nullable=false)
     */
    protected $situacao;
    
    /**
     * @ORM\ManyToOne(targetEntity="Agp\CoreBundle\Entity\ListaPreco", fetch="LAZY")
     * @ORM\JoinColumn(name="cod_setor", referencedColumnName="cod_lista_preco", onDelete="restrict", nullable=true)
     */
    protected $setor;

    public function isAtivo(){
        return $this->situacao == self::SIT_ATIVO;
    }

    public function __construct() {
        $this->situacao = self::SIT_ATIVO;
        $this->confirmado = true;
    }

    public function getCodItemVenda() {
        return $this->codItemVenda;
    }

    public function setCodItemVenda($codItemVenda) {
        $this->codItemVenda = $codItemVenda;
    }

    public function getValorTotalItem(){
        return $this->getQtdItem()*$this->getVlrItem();
    }
    
    public function getVenda() {
        return $this->venda;
    }

    public function setVenda($venda) {
        $this->venda = $venda;
    }

    public function getProduto() {
        return $this->produto;
    }

    public function setProduto($produto) {
        $this->produto = $produto;
    }

    public function getNmTicket() {
        return $this->nmTicket;
    }

    public function setNmTicket($nmTicket) {
        $this->nmTicket = $nmTicket;
    }

    public function getVlrItem() {
        return $this->vlrItem;
    }

    public function setVlrItem($vlrItem) {
        $this->vlrItem = $vlrItem;
    }

    public function getQtdItem() {
        return $this->qtdItem;
    }

    public function setQtdItem($qtdItem) {
        $this->qtdItem = $qtdItem;
    }
    
    public function getSubtotal() {
        return $this->subtotal;
    }

    public function setSubtotal($subtotal) {
        $this->subtotal = $subtotal;
    }
    
    public function getPlacaVel() {
        return $this->placaVel;
    }

    public function setPlacaVel($placaVel) {
        $this->placaVel = $placaVel;
    }

    public function getLista() {
        return $this->lista;
    }

    public function setLista($lista) {
        $this->lista = $lista;
    }
    
    public function getSituacao() {
        return $this->situacao;
    }

    public function setSituacao($situacao) {
        $this->situacao = $situacao;
    }
    
    public function getSetor() {
        return $this->setor;
    }

    public function setSetor($setor) {
        $this->setor = $setor;
    }

}

?>
